﻿package model.entity.product;

import java.util.Map;
import java.util.Map.Entry;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name = "Phone")
public class Phone extends Electronic {
	private String band;
	private String camera;
	private String os;
	private boolean threeG;
	
	public String getBand() {
		return band;
	}

	public void setBand(String band) {
		this.band = band;
	}

	public String getCamera() {
		return camera;
	}

	public void setCamera(String camera) {
		this.camera = camera;
	}

	public String getOs() {
		return os;
	}

	public void setOs(String os) {
		this.os = os;
	}

	public boolean isThreeG() {
		return threeG;
	}

	public void setThreeG(boolean threeG) {
		this.threeG = threeG;
	}

	@Override
	public String toString() {
		return "Phone [band=" + band + ", camera=" + camera + ", os=" + os
				+ ", threeG=" + threeG + ", id=" + id + ", name=" + name
				+ ", price=" + price + ", image=" + image + ", quantity="
				+ quantity + ", extraInfo=" + extraInfo + ", brand=" + brand
				+ ", state=" + state + ", size="+ size +"]";
	}

	public static Map<String, Class<?>> fieldMap(){
		Map<String, Class<?>> fieldMap = Electronic.fieldMap();
		fieldMap.put("band", String.class);
		fieldMap.put("camera", String.class);
		fieldMap.put("os", String.class);
		fieldMap.put("threeG", boolean.class);
		return fieldMap;
	}
	
	@Override
	public void insertData(Map<String, Object> valueMap) {
		super.insertData(valueMap);
		for (Entry<String, Object> entry : valueMap.entrySet()) {
			Object value = entry.getValue();
			
			//Dk rong
			if(entry.getValue() == null) continue;
			
			switch (entry.getKey()) {
			case "band":
				this.band = (String) value;
				break;
			case "camera":
				this.camera = (String) value;
				break;
			case "os":
				this.os = (String) value;
				break;
			case "threeG":
				this.threeG = (boolean) value;
				break;
			default:
				break;
			}
		}
	}
}
